<!DOCTYPE html>
<!--
Copyright (c) 2013 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<link rel="stylesheet" href="/tracing/ui/extras/chrome/gpu/state_view.css">

<link rel="import" href="/tracing/ui/analysis/object_snapshot_view.html">

<script>
'use strict';

tr.exportTo('tr.ui.e.chrome.gpu', function() {
  /*
   * Displays a GPU state snapshot in a human readable form.
   * @constructor
   */
  const StateSnapshotView = tr.ui.b.define(
      'tr-ui-e-chrome-gpu-state-snapshot-view',
      tr.ui.analysis.ObjectSnapshotView);

  StateSnapshotView.prototype = {
    __proto__: tr.ui.analysis.ObjectSnapshotView.prototype,

    decorate() {
      Polymer.dom(this).classList.add('tr-ui-e-chrome-gpu-state-snapshot-view');
      this.screenshotImage_ = document.createElement('img');
      Polymer.dom(this).appendChild(this.screenshotImage_);
    },

    updateContents() {
      if (this.objectSnapshot_ && this.objectSnapshot_.screenshot) {
        this.screenshotImage_.src = 'data:image/png;base64,' +
            this.objectSnapshot_.screenshot;
      }
    }
  };
  tr.ui.analysis.ObjectSnapshotView.register(
      StateSnapshotView,
      {typeName: 'gpu::State'});

  return {
    StateSnapshotView,
  };
});
</script>
